/**
 * infer关键字
 */

/**
 * 在 extends 条件语句后的函数类型的参数类型位置上
 */

import { People } from './S02'
// 常用来提取函数参数的类型
type inferType<T> = T extends (param: infer P) => any ? P : T

/**
 * 在 extends 条件语句后的函数类型的参数类型位置上
 */
// 常用来提取函数返回值的类型
type returnType<T> = T extends (param: any) => infer P ? P : T

/**
 * 出现在类型的泛型具体化类型上
 */
type GetSetType<T> = T extends Set<infer E> ? E : never

interface Customer {
  custname: string
  buymoney: number
}
type PeopleSet = Set<People>

type custFuncType = (cust: Customer) => string

type resType = inferType<custFuncType>
type retType = returnType<custFuncType>
type setType = GetSetType<PeopleSet>
const cust1: resType = { custname: 'wangwdu', buymoney: 23 }
const cust2: retType = 'sss'
